/**
 * Created by lvlq on 16/7/3.
 */
var express = require("express");
var router = express.Router();
var status_enum = require("./status_enum");

/**
 * 给线上系统提供塞用户信息接口
 */
router.post("/setuser", function (req, res) {
    var data = {
        participantId: req.body.participantId,
        activityId: req.body.activityId,
        clientKey: req.body.clientKey,
        player: req.body.player || 1,
        status: status_enum.WAIT,
        username: req.body.username || '',
        points: 0,
        images: "",
        videos: ""
    };

    var Queue = M("index.queue");
    Queue.update(data, {
        where: {
            activityId: data.activityId,
            player: data.player,
        }
    }).then(function () {
        res.json({
            errno: 0
        });
    }).catch(function (err) {
        res.json({
            errno: 10001,
            err: err.message
        });
    });
});

module.exports = router;